package dfbz.com.dao;

import dfbz.com.annotation.MyField;
import dfbz.com.annotation.Table;
import dfbz.com.constant.Const;
import dfbz.com.dao.base.BaseDao;
import dfbz.com.model.UserInfo;
import dfbz.com.service.UserInfoService;
import dfbz.com.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static dfbz.com.constant.Const.MAX_PAGE_SIZE;

public class UserInfoDao extends BaseDao<UserInfo> {
    public List<Map<String, Object>> findList(Integer userId,int page) {
        QueryRunner qr = new QueryRunner(JDBCUtil.getDataSource());
        List<Map<String, Object>> maps = new ArrayList<>();
        try {
            String sql = "select*from user_info limit ?,?";
            maps = qr.query(sql, new MapListHandler(),(page-1)*MAX_PAGE_SIZE,page*MAX_PAGE_SIZE);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return maps;
    }


//    public int total(){
////        req.getSession().setAttribute("umsgList", umsgService.findAll());
////        return UserInfoService
//    }







}